<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Converts keys specifying an index to its identifying string</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongocollection.setwriteconcern.html">« MongoCollection::setWriteConcern</a></li>
      <li style="float: right;"><a href="mongocollection.--tostring.html">MongoCollection::__toString »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongocollection.html">MongoCollection</a></li>
    <li>Converts keys specifying an index to its identifying string</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongocollection.toindexstring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCollection::toIndexString</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoCollection::toIndexString</span> &mdash; <span class="dc-title">Converts keys specifying an index to its identifying string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocollection.toindexstring-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">static protected</span> <span class="methodname"><strong>MongoCollection::toIndexString</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$keys</code></span>): <span class="type">string</span></div>

  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    This method is deprecated since version 1.5.0.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongocollection.toindexstring-parameters">
  <h3 class="title">Parameters</h3>  
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">keys</code>
     </dt>

     <dd>

      <p class="para">
       Field or fields to convert to the identifying string
      </p>
     </dd>

       
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocollection.toindexstring-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a string that describes the index.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocollection.toindexstring-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-133">
   <p><strong>Example #1 <span class="function"><strong>MongoCollection::toIndexString()</strong></span> example</strong></p>
   <div class="example-contents"><p>This example shows how you can create an index name out of keys.
   Because this is a protected (static) method, you need to overload it in a
   child class first.</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;inherited&nbsp;class&nbsp;to&nbsp;make&nbsp;the&nbsp;method&nbsp;"public".<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">MyCollection&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">MongoCollection<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />echo&nbsp;</span><span style="color: #0000BB">MyCollection</span><span style="color: #007700">::</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;Outputs:&nbsp;foo_1<br /><br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">MyCollection</span><span style="color: #007700">::</span><span style="color: #0000BB">toIndexString</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'age'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">)),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;Outputs:&nbsp;name_1_age_-1<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocollection.toindexstring-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   MongoDB core docs on <a href="https://docs.mongodb.com/manual/indexes/" class="link external">&raquo;&nbsp;indexes</a>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongocollection.toindexstring-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongo 1.5.0</td>
       <td>
        This method has been deprecated.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


</div></div></div></body></html>